package com.zmn.plat.services.impl.product.tariff;

import java.util.List;

import javax.annotation.Resource;

import com.zmn.plat.model.dto.product.ProductTariffRelationDTO;
import com.zmn.plat.model.entity.category.ServCategAndCategTwoQuery;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import com.zmn.plat.model.entity.product.tariff.ProductTariff;
import com.zmn.plat.model.entity.product.tariff.ProductTariffQuery;
import com.zmn.plat.model.vo.product.tariff.ProductTariffExportVO;
import com.zmn.plat.model.vo.product.tariff.ProductTariffVO;
import com.zmn.plat.persistence.interfaces.product.tariff.ProductTariffDao;
import com.zmn.plat.services.interfaces.product.tariff.ProductTariffService;

@Service
public class ProductTariffServiceImpl implements ProductTariffService {

    @Resource
    ProductTariffDao productFaultTariffDao;

    @Override
    public ProductTariff findByKey(Integer relateId) {
        return productFaultTariffDao.findByKey(relateId);
    }

    @Override
    public ProductTariff findByTariffId(Integer tariffId) {
        return productFaultTariffDao.findByTariffId(tariffId);
    }

    @Override
    public List<ProductTariffVO> findByKeys(List<Integer> ids) {
        return productFaultTariffDao.findByKeys(ids);
    }

    @Override
    public List<ProductTariffVO> listPageByQuery(ProductTariffQuery query) {
        int count = countByQuery(query);
        query.setTotalCount(count);
        return productFaultTariffDao.listPageByQuery(query);
    }

    @Override
    public List<ProductTariffVO> listByQuery(ProductTariffQuery query) {
        return productFaultTariffDao.listByQuery(query);
    }

    @Override
    @Cacheable(cacheNames = "redis10m", key = "'price:productTariff:listByQuery:ProductTariffQuery:'+#p0", unless = "#result == null")
    public List<ProductTariffVO> listByQueryWithCache(ProductTariffQuery query) {
        return productFaultTariffDao.listByQuery(query);
    }

    @Override
    public List<ProductTariffExportVO> listExportExcelPageByQuery(ProductTariffQuery query) {
        return productFaultTariffDao.listExportExcelPageByQuery(query);
    }

    @Override
    public List<ProductTariff> listByTariffIdAndServCategIdAndCategOneId(Integer newTariffId, Integer servCategId, Integer categOneId) {
        return productFaultTariffDao.listByTariffIdAndServCategIdAndCategOneId(newTariffId, servCategId, categOneId);
    }

    @Override
    public List<ProductTariffRelationDTO> listByProductIdsAndBizTypeAndGeneral(List<Integer> productIds, Integer channelId,Integer bizType, Integer general,Integer tariffType,List<ServCategAndCategTwoQuery> servCategAndCategTwoQueryList) {
        return productFaultTariffDao.listByProductIdsAndBizTypeAndGeneral(productIds, channelId,bizType, general,tariffType,servCategAndCategTwoQueryList);
    }

    @Override
    public List<ProductTariffRelationDTO> listByProductIdsAndBizTypeAndTariffId(List<Integer> productIds, Integer channelId,Integer bizType, Integer tariffId,List<ServCategAndCategTwoQuery> servCategAndCategTwoQueryList) {
        return productFaultTariffDao.listByProductIdsAndBizTypeAndTariffId(productIds, channelId,bizType, tariffId,servCategAndCategTwoQueryList);
    }

    @Override
    public List<ProductTariff> listAll() {
        return productFaultTariffDao.listAll();
    }

    @Override
    public Integer countByQuery(ProductTariffQuery query) {
        return productFaultTariffDao.countByQuery(query);
    }

    @Override
    public Integer updateStatusByKey(ProductTariff productFaultTariff) {
        return productFaultTariffDao.updateStatusByKey(productFaultTariff);
    }

    @Override
    public Integer updateStatusBatchByKey(List<Integer> ids, Integer status, String mcStaffName) {
        return productFaultTariffDao.updateBatchStatusByKey(ids, status, mcStaffName);
    }

    @Override
    public Integer updateByKey(ProductTariff productFaultTariff) {
        return productFaultTariffDao.updateByKey(productFaultTariff);
    }

    @Override
    public Integer updateStatusByProductIdOrTariffId(Integer productId, Integer tariffId, Integer status, String updater) {
        return productFaultTariffDao.updateStatusByProductIdOrTariffId(productId, tariffId, status, updater);
    }

    @Override
    public Integer disableStatusByTariffId(List<Integer> tariffIds, String updater) {
        return productFaultTariffDao.disableStatusByTariffId(tariffIds, updater);
    }

    @Override
    public Integer updateStatusByTariffIds(List<Integer> tariffIds, Integer status, String updater) {
        return productFaultTariffDao.updateStatusByTariffIds(tariffIds, status, updater);
    }

    @Override
    public Integer insert(ProductTariff productFaultTariff) {
        return productFaultTariffDao.insert(productFaultTariff);
    }

    @Override
    public Integer insertBatch(List<ProductTariff> productFaultTariffList) {
        return productFaultTariffDao.insertBatch(productFaultTariffList);
    }

    @Override
    public Integer deleteByKey(Integer relateId) {
        return productFaultTariffDao.deleteByKey(relateId);
    }

    @Override
    public Integer deleteByTariffIdAndServCategIdAndCategOneId(Integer tariffId, Integer servCategId, Integer categOneId) {
        return productFaultTariffDao.deleteByTariffIdAndServCategIdAndCategOneId(tariffId, servCategId, categOneId);
    }
}